home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ADA Programming Guide
/
ADA Programming Guide.iso
/
ada_tut
/
janus16.pkg
< prev
next >
Wrap
Text File
|
1996-01-30
|
3KB
|
61 lines
-- JANUS16.PKG Ver. 3.00 22-AUG-1994 Copyright 1988-1994 John J. Herro
-- Software Innovations Technology
-- 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706 (407)951-0233
--
-- Compile this before compiling ADA_TUTR.ADA, when using a PC with a 16-bit
-- version of Janus/Ada.
--
with Text2_IO; use Text2_IO;
package Custom_IO is
type Color is (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White);
Foregrnd_Color : Color := White; -- Default values in case
Backgrnd_Color : Color := Black; -- ADA-TUTR finds no User
Border_Color : Color := Black; -- File.
Fore_Color_Digit : Character := Character'Val(Color'Pos(Foregrnd_Color)+48);
Back_Color_Digit : Character := Character'Val(Color'Pos(Backgrnd_Color)+48);
Normal_Colors : String(1 .. 10) := ASCII.ESC & "[0;3" &
Fore_Color_Digit & ";4" & Back_Color_Digit & "m";
Clear_Scrn : constant String := ASCII.ESC & "[H" & ASCII.ESC &"[2J";
procedure Set_Border_Color (To : In Color);
procedure Get (Char : out Character);
procedure Put (Char : in Character) renames Text2_IO.Put;
procedure Put (Str : in String) renames Text2_IO.Put;
procedure Put_Line (Str : in String) renames Text2_IO.Put_Line;
procedure Get_Line (Str : out String;
Last : out Natural) renames Text2_IO.Get_Line;
procedure New_Line(Spacing : in Positive_Count := 1)
renames Text2_IO.New_Line;
end Custom_IO;
with Doscall, System; use Doscall, System;
package body Custom_IO is
procedure Set_Border_Color(To : in Color) is
--
-- This procedure sets the border color on a PC by calling interrupt
-- 10 hex. Before the call, register AH is set to service number
-- 0B hex, BH is set to zero, and BL is set to an integer as shown in
-- the declaration of Color_Number below. Note that the integers in
-- Color_Number are bit reversed from the integers defining foreground
-- and background colors in ANSI escape sequences. Note also that some
-- color PCs don't have separate border colors.
--
Regs : Simple_Regs;
Color_Number : constant array(Color) of System.Word :=
(Black => 0, Red => 4, Green => 2, Yellow => 6,
Blue => 1, Magenta => 5, Cyan => 3, White => 7);
begin
Regs.AX := 16#0B00#;
Regs.BX := 16#0000# + Color_Number(To);
Simple_Int_Call(Int_Num => 16#10#, Regs => Regs);
end Set_Border_Color;
procedure Get(Char : out Character) is
Regs : Simple_Regs;
begin
Regs.AX := 16#0800#;
Simple_Int_Call(Int_Num => 16#21#, Regs => Regs);
Char := Character'Val(Regs.AX mod 128);
end Get;
end Custom_IO;